<template>
  <div class="footer-box">
    <div
      v-for="(item, idx) in footerList"
      :key="idx"
      class="footer-item"
      :class="active === item.path ? 'active' : ''"
      @click="changeRouter(item)"
    >
      <van-icon :name="item.meta.icon" />
      <p>{{ item.meta.title }}</p>
    </div>
  </div>
</template>

<script>
import MainPage from "@/router/MainPage.js";
export default {
  name: "footers",
  created() {
    this.active = this.$route.path;
  },
  data() {
    return {
      active: "/main",
      footerList: MainPage,
    };
  },
  methods: {
    changeRouter(item) {
      this.active = item.path;
      this.$router.push(item.path).catch((err) => err);
    },
  },
};
</script>

<style lang="scss" scoped>
.footer-box {
  width: 100%;
  height: 50px;
  border-top: 1px solid #cccc;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.active {
  color: red;
}
.footer-item {
  flex: 1;
  display: flex;
  justify-content: center;
  flex-direction: column;
  align-items: center;
  i {
    font-size: 24px;
  }
  p {
    font-size: 13px;
  }
}
</style>